var landingAjaxSend=false;var scriptIsLoaded=false;BX.ready((function(){var e=BX("landing-create-folder");var n=BX("landing-recycle-bin");var t=BX("grid-tile-inner");if(scriptIsLoaded){return}scriptIsLoaded=true;BX.bind(n,"click",(function(){var e=BX.Main.filterManager.getById(landingFilterId),n=e.getApi(),t=e.getFilterFieldsValues();if(t.DELETED==="Y"){t.DELETED=""}else{t.DELETED="Y"}n.setFields(t);n.apply()}));var a=function(){if(landingAjaxSend){return}landingAjaxSend=true;var e=BX("workarea-content");var n=BX.create("div",{attrs:{className:"landing-filter-loading"}});document.body.appendChild(n);var t=new BX.Loader({size:130,color:"#bfc3c8"});t.show(n);BX.ajax({method:"POST",dataType:"html",url:landingAjaxPath,onsuccess:function(a){landingAjaxSend=false;t.hide();n.classList.add("landing-filter-loading-hide");e.innerHTML=a}})};BX.addCustomEvent("BX.Main.Filter:apply",BX.delegate(a));BX.addCustomEvent("BX.Landing.Filter:apply",BX.delegate(a));if(e){var i=BX.create("input",{props:{type:"text"}});function r(){BX.ajax({url:"/bitrix/tools/landing/ajax.php?"+""+"action=Site::addFolder&"+"type="+BX.data(e,"type"),method:"POST",data:{data:{siteId:BX.data(e,"siteId"),fields:{TITLE:i.value,PARENT_ID:BX.data(e,"folderId")}},sessid:BX.message("bitrix_sessid")},dataType:"json",onsuccess:function(n){if(typeof n.type!=="undefined"&&typeof n.result!=="undefined"){if(n.type==="error"){var t=BX.Landing.UI.Tool.ActionDialog.getInstance();t.show({content:n.result[0].error_description,confirm:"OK",type:"alert"}).then((function(){if(n.result[0].error==="FOLDER_IS_NOT_UNIQUE"){i.value="";i.focus()}else{BX.fireEvent(e,"click")}}))}else{window.location.reload()}}}})}i.addEventListener("keydown",(function(e){if(e.keyCode===13){r()}}));i.addEventListener("blur",(function(){if(i.value.length!==0){r()}}));var d=BX.create("div",{props:{className:"landing-item landing-item-folder"},children:[BX.create("div",{props:{className:"landing-title"},children:[BX.create("div",{props:{className:"landing-title-wrap"},children:[BX.create("div",{props:{className:"landing-title-overflow --create-folder-input"},children:[i]})]})]}),BX.create("div",{props:{className:"landing-item-cover"},children:[BX.create("div",{props:{className:"landing-item-preview"}}),BX.create("div",{props:{className:"landing-item-folder-corner"},children:[BX.create("div",{props:{className:"landing-item-folder-dropdown"}})]})]})]});d.style.display="none";BX.insertAfter(d,document.body.querySelector(".landing-folder-placeholder"));BX.bind(e,"click",(function(){if(!d.prepareNode){BX.insertAfter(d,document.body.querySelector(".landing-folder-placeholder"))}if(BX.hasClass(e,"ui-btn-disabled")){return}d.style.display="block";BX.focus(i)}))}var l=function(e){if(!Array.isArray(landingSettingsButtons)){return}var n=top.location.toString();var t={onClose:function(){if(window["landingSettingsSaved"]===true){top.location=n}if(BX.PopupMenu.getCurrentMenu()){BX.PopupMenu.getCurrentMenu().close()}}};if(landingSettingsButtons.length===1){var a=landingSettingsButtons[0]["dataset"]&&landingSettingsButtons[0]["dataset"]["skipSlider"]===true;if(!a){BX.SidePanel.Instance.open(landingSettingsButtons[0]["href"],{allowChangeHistory:false,events:t})}}else{for(var i=0,r=landingSettingsButtons.length;i<r;i++){landingSettingsButtons[i]["onclick"]=function(e,n){var a=n&&n.dataset&&n.dataset.skipSlider===true;if(!a){BX.SidePanel.Instance.open(n.href,{allowChangeHistory:false,events:t});BX.PreventDefault(e)}BX.PopupMenu.getMenuById("landing-menu-settings").close()}}var d=BX.PopupMenu.getMenuById("landing-menu-settings")||BX.Main.MenuManager.create({id:"landing-menu-settings",bindElement:e.currentTarget,autoHide:true,zIndex:1200,offsetLeft:20,angle:true,closeByEsc:true,items:landingSettingsButtons});d.show()}BX.PreventDefault(e)};if(BX("landing-menu-settings")){BX("landing-menu-settings").addEventListener("click",BX.proxy(l,BX("landing-menu-settings")))}var s=function(e){if(BX.hasClass(BX("landing-create-element"),"ui-btn-disabled")){BX.PreventDefault(e);return}var n=BX.PopupMenu.getMenuById("landing-menu-action")||BX.Main.MenuManager.create({id:"landing-menu-action",bindElement:e.currentTarget,autoHide:true,zIndex:1200,offsetLeft:20,angle:true,closeByEsc:true,items:landingCreateButtons||[]});n.show();BX.PreventDefault(e)};if(BX("landing-menu-actions")){BX("landing-menu-actions").addEventListener("click",BX.proxy(s,BX("landing-menu-actions")))}}));
//# sourceMappingURL=script.map.js